home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-19 | 1.9 KB | 96 lines | [TEXT/CWIE] |
- // main.cp
-
- #ifndef FileCopier_h
- #include "FileCopier.h"
- #endif
- #ifndef __ERRORS__
- #include <Errors.h>
- #endif
- #ifndef __WINDOWS__
- #include <Windows.h>
- #endif
- #ifndef __FONTS__
- #include <Fonts.h>
- #endif
- #ifndef __DIALOGS__
- #include <Dialogs.h>
- #endif
- #ifndef Appearance_h
- #include "Appearance.h"
- #endif
- #ifndef Controls_h
- #include "Controls.h"
- #endif
-
- void main()
- {
- FSSpec spec;
- OSErr error = FSMakeFSSpec( -1, 2, "\pTroops", &spec );
- Assert( error == noErr );
-
- FSSpec spec2;
- error = FSMakeFSSpec( -1, 2, "\pTroops copy", &spec2 );
- if ( error != fnfErr )
- FSpDelete( &spec2 );
-
- static FileCopier copier;
- TaskLife life;
-
- life.Launch( copier( spec, spec2 ) );
-
- InitGraf( &qd.thePort );
- InitFonts();
- InitWindows();
- InitMenus();
- InitDialogs( 0 );
- FlushEvents( everyEvent, 0 );
- RegisterAppearanceClient();
-
- MenuHandle apple = GetMenu( 128 );
- AppendResMenu( apple, 'DRVR' );
- InsertMenu( apple, 0 );
- InsertMenu( GetMenu( 129 ), 0 );
- DialogPtr progress = GetNewDialog( 128, 0, WindowPtr(-1) );
-
- ControlHandle progressBar;
- int16 itemType;
- Rect itemBox;
- GetDialogItem( progress, 2, &itemType, reinterpret_cast<Handle*>(&progressBar), &itemBox );
- DrawMenuBar();
-
- while ( 1 )
- {
- EventRecord event;
- uint32 sleepTime = ApplicationTaskQueue::The().IsEmpty() ? 6 : 0;
- WaitNextEvent( everyEvent, &event, sleepTime, 0 );
-
- if ( IsDialogEvent( &event ) )
- {
- DialogPtr dialog;
- int16 item;
- DialogSelect( &event, &dialog, &item );
- }
-
- switch ( event.what )
- {
- case mouseDown:
- {
- WindowPtr window;
- int16 part = FindWindow( event.where, &window );
- if ( part == inMenuBar )
- if ( MenuSelect( event.where ) != 0 )
- return;
- break;
- }
-
- case nullEvent:
- ApplicationTaskQueue::The().ExecuteOne();
- int32 total = copier.MaxPosition() / 100000;
- int32 position = copier.Position() / 100000;
- if ( total != 0 )
- SetControlValue( progressBar, position*100 / total );
- break;
- }
- }
- }
-